package edu.java.texbooks.tutorial.test02;

public class Book implements Relatable {

    // --- Instance variables --------------------------------------------------
    int countPages = 0;
    final int ISBN;

    // --- Constructors --------------------------------------------------------

    public Book() {
	this(0, 0);
    }

    public Book(int isbn) {
	this(0, isbn);
    }

    public Book(int isbn, int countPages) {
	ISBN = isbn;
	this.countPages = countPages;

    }

    // --- Getters and Setters -------------------------------------------------
    public int getISBN() {
	return ISBN;
    }

    public int getCountPages() {
	return countPages;
    }

    public void setCountPages(int countPages) {
	this.countPages = countPages;
    }

    // --- Override Methods ----------------------------------------------------

    @Override
    public int isLargerThan(Relatable other) {

	if (this.getCountPages() > ((Book) other).getCountPages()) {
	    return 1;
	} else if (this.getCountPages() == ((Book) other).getCountPages()) {
	    return 0;
	} else {
	    return -1;
	}
    }

    @Override
    public boolean equals(Object object) {
	Book tmpBook = (Book) object;

	return this.getISBN() == tmpBook.getISBN()
		&& this.getCountPages() == tmpBook.getCountPages();
    }

    // --- Methods -------------------------------------------------------------
    public static void printInfo() {
	System.out.println("Book info.");
    }

}
